from configparser import ConfigParser
import os


class ReadPath:
    def __init__(self):
        # 获取项目路径
        self.base_path = os.path.dirname(os.getcwd())
        # print(self.base_path)
        # 实例化读取ini文件的类
        self.config = ConfigParser()
        # 获取path.ini文件完整路径
        pathini_path = os.path.join(self.base_path, "config\path.ini")
        # print(pathini_path)
        # 进行文件读取
        with open(pathini_path, encoding="utf-8") as fp:
            self.config.read_file(fp)

    def get_accountinfo_path(self):
        """
        #获取Acountinfo.ini完整路径
        :return:
        """
        relative_path = self.config.get("path", "accountinfo_path")
        return os.path.join(self.base_path, relative_path)

    def get_jsoncase_path(self):
        """
        #获取jsoncase.json完整路径
        :return:
        """
        relative_path = self.config.get("path", "jsoncase_path")
        return os.path.join(self.base_path, relative_path)

    def get_yamlcase_path(self):
        """
        #获取yamlcase.yaml完整路径
        :return:
        """
        relative_path = self.config.get("path", "yamlcase_path")
        return os.path.join(self.base_path, relative_path)

    def get_datapicture_path(self):
        """
        ##获取测试图片父路径
        :return:
        """
        relative_path = self.config.get("path", "data_picture")
        return os.path.join(self.base_path, relative_path)

    def get_datafile_path(self):
        """
        ##获取测试文件父路径
        :return:
        """
        relative_path = self.config.get("path", "data_file")
        return os.path.join(self.base_path, relative_path)

if __name__ == "__main__":
    print(ReadPath().get_accountinfo_path())
    print(ReadPath().get_jsoncase_path())
    print(ReadPath().get_yamlcase_path())
    print(ReadPath().get_datapicture_path())
    print(ReadPath().get_datafile_path())

# print(os.getcwd())
# base_path = os.path.dirname(os.getcwd())
# print(base_path)
# # 实例化读取ini文件的类
# config = ConfigParser()
# # 获取path.ini文件完整路径
# pathini_path = os.path.join(base_path, "config\path.ini")
# print(pathini_path)
